namespace chatroom{
    enum class ChatSessionType{
        SINGAL = 1,
        GROUP = 2
    };
    #pragma db object table("chat_session");
    //聊天会话表
    class chat_session{
    public:
        chat_session(){}
        chat_session(const std::string& session_id,const std::string& session_name,ChatSessionType session_type):_session_id(session_id),_session_name(session_name),_session_type(session_type){}

        void set_session_id(const std::string& val)
        {
            _session_id = val;
        }
        std::string get_session_id()
        {
            return _session_id;
        }

        void set_session_name(const std::string& val)
        {
            _session_name = val;
        }
        std::string get_session_name()
        {
            return _session_name;
        }
        void set_session_type(ChatSessionType val)
        {
            _session_type = val;
        }
        ChatSessionType get_session_type()
        {
            return _session_type;
        }
    private:
        friend class odb::access;
        #pragma db id auto
        unsigned long _id;
        #pragma db type("VARCHAR(64)") index unique
        std::string _session_id;
        #pragma db type("VARCHAR(64)") index
        std::string _session_name;
        #pragma db type("tinyint")
        ChatSessionType _session_type; //1 表示单聊 2 表示群聊
    };

    #pragma db view object(chat_session=css)\
                    object(ChatSessionMember=CSM1 : CSM1::_session_id ==css::_session_id)\
                    object(ChatSessionMember=CSM2 : CSM2::_session_id == css::_session_id)\
                    query((?))
    struct SingalSession{
        #pragma db column(css::_session_id)
        std::string session_id;
        #pragma db column(CSM2::_user_id)
        std::string friend_id;
    };
    #pragma db view object(chat_session=css)\
                    object(ChatSessionMember=CSM : CSM::_session_id ==css::_session_id)\
                    query((?))
    struct GroupSession{
        #pragma db column(css::_session_id)
        std::string session_id;
        #pragma db column(css::_session_name)
        std::string friend_id;
    };
}